<%@page import="com.wanmait.cookbook.vo.Cookbook"%>
<%@page import="java.util.List"%>
<%@page import="com.wanmait.cookbook.vo.Pager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%String path = request.getContextPath(); %>
<table class="result-tab" width="100%">
					<tr>
						<th class="tc" width="5%"><input class="allChoose" name=""
							type="checkbox"></th>
						<th>序号</th>
						<th>设置热门</th>
						<th>食谱名称</th>
						<th>分类</th>
						<th>图片</th>
						<th>上传者</th>
						<th>浏览量</th>
						<th>上传时间</th>
						<th>收藏量</th>
						<th>详情</th>
						<th>操作</th>
					</tr>
					<%
                        	List<Cookbook> allCookbook =(List<Cookbook>)request.getAttribute("allCookbook");
                        	List<Integer> cookbookCollectCounts =(List<Integer>)request.getAttribute("nums");
                        	for(int i=0;i<allCookbook.size();i++) {	
                        %>
					<tr id="tr<%=allCookbook.get(i).getId()%>">
						<td class="tc"><input data-id="<%=allCookbook.get(i).getId() %>" class="choose" name="id[]"
							type="checkbox"></td>
						<td><%=i+1 %></td>
						<td><select class="sethot" data-userinfoid="<%=allCookbook.get(i).getUserinfo().getId() %>"
							data-id="<%=allCookbook.get(i).getId() %>" name="hot">
								<%if(allCookbook.get(i).getHot()) {%>
								<option value="1">热门</option>
								<option value="0">不热门</option>
								<%} else{%>
								<option value="0">不热门</option>
								<option value="1">热门</option>
								<%} %>
						</select></td>
						<td><%=allCookbook.get(i).getTitle() %></td>
						<td><%=allCookbook.get(i).getRecipeTypeSecond().getTitle() %></td>
						<td><img
							src="<%=path%>/static/image/<%=allCookbook.get(i).getPic() %>"
							width="50" height="50"></td>
						<td><%=allCookbook.get(i).getUserinfo().getName() %></td>
						<td><%=allCookbook.get(i).getPageviews() %></td>
						<td><%=allCookbook.get(i).getInputTime() %></td>
						<td><%=cookbookCollectCounts.get(i) %></td>
						

						<td><a class="aaa" data-id="<%=allCookbook.get(i).getId() %>"
							src="javascript:void(0)">详情</a></td>
						<td><a class="link-del"
							id="del<%=allCookbook.get(i).getId() %>"
							href="javascript:void(0)">删除</a></td>
					</tr>
					<!-- 详情弹窗 -->
						<style>
						.divv {
							width: 800;
							height: 800;
							display: none;
						}
						</style>
						<div id="ifr<%=allCookbook.get(i).getId() %>" style="float: left; width: 1000px; height: 600px" class="divv">
							<iframe id="myiframe" style="float: left;" src="<%=path %>/CookbookManageServlet?action=getCookbookItem&id=<%=allCookbook.get(i).getId() %>" width=1100px height=600px></iframe>
						</div>
						<!-- 详情弹窗结束 -->
					<%
                        	}
                        %>
				</table>
					<div class="list-page">
					<a id="prev" href="javascript:void(0);">上一页</a>
							<!-- 显示数字 -->
							<%Pager pager = (Pager)request.getAttribute("pager"); %>
							<%
							int start = 1;
							int end = pager.getPageCount();
							if(pager.getPageCount()>5)
							{
								start = pager.getPageNo()-2<1?1:pager.getPageNo()-2;
								end = start+4;
								if(end>pager.getPageCount())
								{
									end = pager.getPageCount();
									start = end-4;
								}
							}
							for (int i = start; i <= end; i++) {
								if(pager.getPageNo()!=i){
							%>
							<a class="number" href="javascript:void(0);"><%=i%></a>
							<%
								}else{
							%>
							<a id="pagerColor" class="number" href="javascript:void(0);"><%=i%></a>
							<%
								}
							}
							%>
							<!-- 显示数字的结束 -->
							<a id="next" data-id="<%=pager.getPageNo() %>" href="javascript:void(0);">下一页</a>
							共<%=pager.getPageCount() %>页
						</div>
						<script src="<%=request.getContextPath()%>/manage/js/jquery.min.js"></script>
						<script>
							$(function(){
								$("#pagerColor").css("color","red");
								//下一页
									$("#next").click(function(){
								 	var n =<%=pager.getPageNo()%>
								 	if(n!=<%=pager.getPageCount()%>){
									 $.ajax({
											url:"<%=request.getContextPath()%>/CookbookManageServlet?action=getManageAllCookbookListNextPager",
											type:"post",
											data:{pageNo:n+1},
											success:function(mes){
								
												$(".result-content").html(mes);
											}
										});//ajax的结束
								 	}
								});
									//上一页
									$("#prev").click(function(){
									 	var n =<%=pager.getPageNo()%>
									 	if(n!=1){
										 $.ajax({
												url:"<%=request.getContextPath()%>/CookbookManageServlet?action=getManageAllCookbookListNextPager",
												type:"post",
												data:{pageNo:n-1},
												success:function(mes){
									
													$(".result-content").html(mes);
												}
											});//ajax的结束
									 	}
									});
							});
			
						</script>